import 'package:flutter/material.dart';
import 'package:flutter_crud_test_amir_rabbani/core/resource/my_colors.dart';
import 'package:flutter_crud_test_amir_rabbani/core/widgets/base_stateless.dart';

class Input extends BaseStateless {
  String? hint, title;
  TextEditingController? controller;
  double? fontSize;
  Function(String t)? onSubmitted;
  Function(String t)? onChanged;
  List<String>? autofillHints;

  Input(
      {this.hint,
      this.title,
      this.controller,
      this.fontSize = 15,
      this.onSubmitted,
      this.onChanged,
      this.autofillHints,
      Key? key})
      : super(key: key);

  @override
  Widget buildState(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        if (title != null)
          Padding(
            padding: const EdgeInsets.only(right: 10, bottom: 10),
            child: Text(
              title ?? '',
              style: textTheme.bodyLarge,
            ),
          ),
        Container(
          height: 48,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(8),
          ),
          child: TextField(
            controller: controller,
            obscuringCharacter: '*',
            onSubmitted: onSubmitted,
            style: textTheme.bodyLarge,
            autofillHints: autofillHints,
            autocorrect: true,
            onChanged: onChanged,
            decoration: InputDecoration(
              enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(8),
                  borderSide: BorderSide(
                      color: Theme.of(context)
                          .inputDecorationTheme
                          .border!
                          .borderSide
                          .color)),
              contentPadding: const EdgeInsets.symmetric(horizontal: 20),
              hintText: hint ?? '',
            ),
          ),
        ),
      ],
    );
  }
}
